<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>内容选择器</title>
    <script src="../../js/jquery-1.4.2.js"></script>
    <style>
        body {
            font-family: "微软雅黑";
        }

        div, span {
            width: 140px;
            height: 140px;
            margin: 20px;
            border: 1px solid #000;
            float: left;
            font-size: 17px;
            font-family: Roman;
        }

        div.mini {
            width: 40px;
            height: 43px;
            background: #CC66FF;
            border: 1px solid #000;
            font-size: 12px;
            font-family: Roman;
        }

        input {
            margin: 5px 5px;
        }
    </style>
</head>
<body>
    <input type="button" id="b1" value="改变包含id属性的div元素的背景颜色为#FF6347">
    <input type="button" id="b2" value="改变包含属性title='aa'的div元素背景颜色为#9ACD32">
    <input type="button" id="b3" value="改变div的第一个子元素的背景颜色为#FF6984">
    <input type="button" id="b4" value="改变div的第二个子元素的背景颜色为#006400">

    <hr>

    <h1>天气热了</h1>

    <div id="one">id是one</div>

    <div id="two" class="mini">
        id为two,class是mini
        <div class="mini">class是mini</div>
    </div>

    <div class="one" title="aa">
        class是one
        <div class="mini"></div>
        <div class="mini">class是mini</div>
    </div>

    <br>

    <div id="mover">动画</div>
    <br>
    <div style="display: none">看不见我，看不见我......</div>

</body>
<script>
    //让整个页面加载完成就执行
    $(function () {
        //1.改变包含id属性的div元素的背景颜色为#FF6347
        $("#b1").click(function(){
            $("div[id]").css("background","#FF6347")
        })
        //2.改变包含属性title='aa'的div元素背景颜色为#9ACD32
        $("#b2").click(function(){
            $("div[title='aa']").css("background","#9ACD32")
        })
        //3.改变div的第一个子元素的背景颜色为#FF6984
        $("#b3").click(function(){
            $("div:first-child").css("background","#FF6984")
        })
        //4.改变div的第二个子元素的背景颜色为#006400
        $("#b4").click(function(){
            $("div:nth-child(2)").css("background","#006400")
        })
    })
</script>
</html>